// 分类模型
const { CategoryOne,CategoryTwo,CategoryThree } = require('../../../models/category');
// 统一数据返回类
const { DataReturn } = require('../../../common/returnclass');

module.exports = async (req, res) => {

		// populate: {
		// 	path: 'children',
		// 	model: CategoryThree
		// }
		let { _id } = req.query;
		console.log(req.query);
		
		// 根据分类id查询分类
		let category = await CategoryOne.findOne({_id}).populate({ 
			path: 'children', model: CategoryTwo ,
			populate: {
				path: 'children',
				model: CategoryThree
			} 
		});
		
		if (!category) return DataReturn.getData(res,200, category,'暂无分类数据')
		// 响应 商品分类
		return DataReturn.getData(res,200, category,'获取分类列表成功')

};